$(function(){
    obj.init();
});
var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dom: {
            btnView: null,
            frame:null,
        },
        init: function () {
            this.dom.btnView = $('#btn_view');
            this.dom.frame   = $('iframe');
            this.listener();
        },
        listener: function () {
            var $this = this;
            //点击查询
            $this.dom.btnView.click(function () {
                $this.funObj().viewUsage();
            });
            //加载完毕后关闭提示
            $this.dom.frame.load(function(){
                window.top.swal.close();
            });
        },
        funObj: function(){
            var $this = this;
            return {
                viewUsage: function () {
                    $this.dom.frame.attr('src', '');
                    setTimeout(function () {
                        var startTime   = $('#startTime').val(),
                            endTime     = $('#endTime').val(),
                            iSBLId      = $('#iSBLId').val()
                        if (!startTime || !endTime) {
                            window.top.xhTop.showError('时间不能为空！');
                            xhExtra.setBtnNormal($this.dom.btnView);
                            return false;
                        }
                        $this.dom.frame.attr('src',
                            baseUrl + 'school_book/useDetail?'
                            + xhTool.parseParam({iSBLId: iSBLId, startTime: startTime, endTime: endTime})
                        );
                        xhExtra.setBtnNormal($this.dom.btnView);
                        // window.top.swal({
                        //     title: '统计执行中！请耐心等待...',
                        //     showConfirmButton: false,
                        //     type: 'success',
                        //     allowOutsideClick: false
                        // });
                        // setTimeout(function () {
                        //     xhExtra.setBtnNormal($this.dom.btnView);
                        //     window.top.swal.close();
                        // }, 30 * 1000);
                    }, 0);
                }
            }
        }
    }
}